const INFO_KEY = 'hm_shopping_info'
const HISTORY_SEARCH_KEY = 'hm_history_search_info'

export const getInfo = () => {
  const info = localStorage.getItem(INFO_KEY)
  return info ? JSON.parse(info) : { userId: '', token: '' }
}

export const setInfo = (info) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(info))
}

export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY)
}

export const getHistorySearch = () => {
  const info = localStorage.getItem(HISTORY_SEARCH_KEY)
  return info ? JSON.parse(info) : []
}

export const setHistorySearch = (info) => {
  localStorage.setItem(HISTORY_SEARCH_KEY, JSON.stringify(info))
}
